Ext.define('appfe.stockor.statist.buyinpoint.form.BuyinPointLogGrid', {
    extend: 'Ext.grid.Panel',
    xtype: 'buyin-point-log-grid',
    alias: 'widget.stockor.statist.buyinpoint.form.BuyinPointLogGrid',
    requires: [
        'appfe.stockor.statist.buyinpoint.form.BuyinPointLogGridController'
    ],
    controller: 'stockor.statist.buyinpoint.form.BuyinPointLogGrid',
    viewModel: {
        data: {
            buyinPoint: {
                id: '',
                slimsymbol: '',
                stkname: '',
                grade: ''
            }
        },
        stores: {
            buyinPointLogStore: {
                fields: [
                    { name: 'id', type: 'int' },
                    { name: 'slimsymbol', type: 'string' },
                    { name: 'name', type: 'string' },
                    { name: 'grade', type: 'string' },
                    { name: 'infoTime', type: 'date' },
                    { name: 'topenPrice', type: 'float' },
                    { name: 'tclosePrice', type: 'float' },
                    { name: 'thighPrice', type: 'float' },
                    { name: 'tlowPrice', type: 'float' },
                    { name: 'status', type: 'string' },
                    { name: 'tcloseIncreaseAmount', type: 'float' },
                    { name: 'tcloseProfitRatio', type: 'float' },
                    { name: 'closeOverMa5', type: 'boolean' },
                    { name: 'ma5OverMa10', type: 'boolean' },
                    { name: 'ma5OverMa13', type: 'boolean' },
                    { name: 'macdSlope', type: 'float' },
                    { name: 'createDate', type: 'date' },
                    { name: 'modifyDate', type: 'date' },
                    { name: 'comments', type: 'string' }
                ],
                autoLoad: false,
                remoteSort: true,
                proxy: {
                    type: 'ajax',
                    url: BizHttpAction.queryZenBuyinPointGrowingLogByPointId.url,
                    reader: {
                        type: 'json',
                        rootProperty: 'data',
                        totalProperty: 'total',
                        successProperty: 'success'
                    },
                    // extraParams: {
                    //     parentid: '{buyinPoint.id}'
                    // },
                    simpleSortMode: true
                },
                sorters: [
                    { property: 'infoTime', direction: 'DESC' }
                ]
            }
        }
    },
    bind: {
        store: '{buyinPointLogStore}',
        title: '<span style="font-weight:bold;font-size: 16px;color:LightGoldenrodYellow;">ID:{buyinPoint.id}, &nbsp;&nbsp;简码:{buyinPoint.slimsymbol}, &nbsp;&nbsp;名称:{buyinPoint.stkname}, &nbsp;&nbsp;级别:{buyinPoint.grade}</span> '
    },
    viewConfig: {
        trackOver: true, // 鼠标滑过当前行时, 反显
        stripeRows: true, // 行颜色白灰条纹间隔显示
        enableTextSelection: true, // 允许选择文本
        emptyText: '点击查询按钮',
        deferEmptyText: false
    },
    //iconCls: 'x-fa fa-gears',
    animCollapse: false,
    collapsible: false,
    columnLines: true, // 表格分隔线
    border: false,
    autoLoad: false,
    // frame: true,
    //
    disableSelection: false,
    autoScroll: true,
    loadMask: true, // 显示数据加载中蒙层
    selModel: {
        type: 'checkboxmodel', //带选择框
        injectCheckbox: 0, //checkbox位于哪一列，默认值为0
        mode: 'SINGLE', //支持三种模式 'SINGLE' / 'SIMPLE' / 'MULTI'支持ctrl,shift的操作 
        allowDeselect: true, //mode: 'SINGLE'下才有效
        checkOnly: false //只能点击checkbox才能选中
    },
    columns: {
        defaults: {
            sortable: false,
            menuDisabled: true,
            //flex: 2
            defaults: {
                sortable: false,
                menuDisabled: true
            }
        },
        items: [
            { xtype: 'rownumberer', resizable: true }, //显示行数
            // { text: 'ID', width: 90, dataIndex: 'id' },
            // { text: '代码', width: 90, dataIndex: 'slimsymbol' },
            // { text: '名称', minWidth: 90, maxWidth: 550, dataIndex: 'name' },
            // { text: '级别', width: 60, dataIndex: 'grade', },
            { xtype: 'datecolumn', text: '时间', width: 100, dataIndex: 'infoTime', format: 'Y-m-d' },
            {
                text: '交易四价',
                columns: [
                    { xtype: 'numbercolumn', text: '开', width: 80, dataIndex: 'topenPrice', align: 'right', format: '￥0.00' },
                    { xtype: 'numbercolumn', text: '收', width: 80, dataIndex: 'tclosePrice', align: 'right', format: '￥0.00' },
                    { xtype: 'numbercolumn', text: '高', width: 80, dataIndex: 'thighPrice', align: 'right', format: '￥0.00' },
                    { xtype: 'numbercolumn', text: '低', width: 80, dataIndex: 'tlowPrice', align: 'right', format: '￥0.00' }
                ]
            },
            { text: '状态', width: 80, dataIndex: 'status', renderer: 'viewCellStatusRender' },
            {
                text: '利润',
                columns: [
                    { xtype: 'numbercolumn', text: '额', width: 80, dataIndex: 'tcloseIncreaseAmount', align: 'right', renderer: 'viewCellProfitAmountRender' }, //, format: '￥0.00'
                    { xtype: 'numbercolumn', text: '率', width: 100, dataIndex: 'tcloseProfitRatio', align: 'right', renderer: 'viewCellProfitRatioRender' }//, renderer: function (rate) { return Ext.util.Format.number(rate * 100, '0.00%'); } 
                ]
            },
            {
                text: '均价位置',
                columns: [
                    { text: '收价≥均5', width: 80, dataIndex: 'closeOverMa5', renderer: 'viewCellBooleanRender' },
                    { text: '均5≥均10', width: 80, dataIndex: 'ma5OverMa10', renderer: 'viewCellBooleanRender' },
                    { text: '均5≥均13', width: 80, dataIndex: 'ma5OverMa13', renderer: 'viewCellBooleanRender' },
                    { text: 'MACD斜率', width: 90, dataIndex: 'macdSlope', format: '0.0000%' }
                ]
            },
            { xtype: 'datecolumn', text: '创建时间', width: 160, dataIndex: 'createDate', format: 'Y-m-d H:i:s' },
            { xtype: 'datecolumn', text: '修改时间', width: 160, dataIndex: 'modifyDate', format: 'Y-m-d H:i:s' },
            { text: '备注', flex: 1, dataIndex: 'comments', producesHTML: false, renderer: 'viewCellPlainTextRender' }
        ]
    },
    listeners: {
        render: 'onRender',
        boxready: 'onBoxReady'
    }
});